import React, {Component} from 'react';
import { Title } from './mixin' 
import { connect } from 'react-redux'
import { detailShow, getDetail } from './detail.redux'

@connect(state => state,{detailShow,getDetail})
class CrisisList extends Component{
  componentDidMount(){
    this.props.getDetail()
  }
  render(){
    const types = {'-1':'全部网站','0':'新闻','1':'论坛',
    '2':'微博','3':'平面媒体','5':'博客','6':'贴吧',
    '9':'twitter','10':'微信','11':'招标','12':'手机App','13':'笑话',}

    const _list = this.props.data
    if(_list.length > 0){
      var list = _list.map((d,i) =>{
        return (
          <div className="list" key={i.toString()} >
            <div className='top'>
              <div className="source">{types[d.webSiteType.toString()]}</div>
              <div className="time">{d.poTime}</div>
            </div>
            <div className="cont" onClick = {() => {this.props.detailShow(i)}}>{d.title}</div>
          </div>
        )
      })
    }
    
    return (
      <div className="crisislist">
        {list}
      </div>
    )
  }

}
class Crisis extends Component{
  render(){
    return (
      <div className="crisis">
        <Title name="危机舆情" el="Traffic information"/>
        <CrisisList />
      </div>
    )
  }
}

export default Crisis